/*
 * $Id: Box.java 112 2009-05-06 14:35:48Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.gui.deltagui.widget.box;

import java.awt.Graphics2D;
import java.util.LinkedList;
import java.util.List;

import deltadesk.gui.deltagui.layout.SingleControlLayout;
import deltadesk.gui.deltagui.widget.Composite;


/**
 * Box.
 * 
 * @author Andreas Meyer
 * @version $Revision: 112 $
 */
public class Box extends Composite {

	/** A list of box styles. */
	private static final List<BoxStyle> styles;
	
	/** The current styles index. */
	private static int styleIndex;

	
	static {

		styles = new LinkedList<BoxStyle>();
		styles.add(new DefaultBoxStyle());
		styles.add(new FastBoxStyle());
		styles.add(new FormBoxStyle());
		styles.add(new iBoxStyle());
		styles.add(new PlasticBoxStyle());
		styles.add(new BlackWhiteGradientBoxStyle(Direction.HORIZONTAL));
		styles.add(new BlackWhiteGradientBoxStyle(Direction.HORIZONTAL_RAISED));
		styles.add(new BlackWhiteGradientBoxStyle(Direction.VERTICAL));
		styles.add(new BlackWhiteGradientBoxStyle(Direction.VERTICAL_RAISED));
	}

	/**
	 * Construct the box.
	 */
	public Box() {
		
		setBackgroundColor(null);
		setInsets(10);
		setLayout(new SingleControlLayout());
	}

	/**
	 * Switch to the next style.
	 */
	public static void nextStyle() {

		styleIndex++;
		if(styleIndex >= styles.size()) {
			styleIndex = 0;
		}
	}

	/**
	 * @see deltadesk.gui.deltagui.widget.Control#renderControl(java.awt.Graphics2D)
	 */
	@Override
	public void renderControl(final Graphics2D g2) {

		final BoxStyle style = styles.get(styleIndex);
		style.render(g2);
	}

}
